<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui"
	lang="en">
	
	<ui:decorate template="/WEB-INF/facelets/faceletListar.xhtml">
		<ui:define name="form">
			<h:form>
					<h:panelGroup id="painelListar" rendered="#{FuncionarioMB.modoListar}">
						
						<p:commandButton action="#{FuncionarioMB.criar}" value="Novo &raquo;" ajax="false"></p:commandButton>
				
						<p></p>
								
						<p:dataTable 
							value="#{FuncionarioMB.lista}" 
							var="obj" 
							selectionMode="single" 
							selection="#{FuncionarioMB.entidade}"
							paginator="true"
							rows="10"
							rowKey="#{obj.id}"
							widgetVar="tabela" 
							emptyMessage="Nenhum registro encontrado."
							rowIndexVar="indice">
							
							<p:column>
								<f:facet name="header">
						       		<h:outputText value="Nº" />
						       	</f:facet>
						       	<div align="center">
						    		<h:outputText value="#{indice + 1}" />
						    	</div>
						    </p:column>
							
							<p:column>
								<f:facet name="header">
						       		<h:outputText value="Nome" />
						       	</f:facet>
						    	<h:outputText value="#{obj.nome}" />
						    </p:column>
						       
					       <p:column>
					       		<f:facet name="header">
					       	   	</f:facet>
								<div align="center">					           
					       			<p:commandButton value="Editar" action="#{FuncionarioMB.editar(obj)}" ajax="false"></p:commandButton>
					       		</div>
					       </p:column>
						</p:dataTable>
					</h:panelGroup>
				
					<h:panelGroup id="painelEditar" rendered="#{FuncionarioMB.modoEditar}">
						<p:messages id="mensagens"></p:messages>	
					
						<fieldset>
							<legend>Formulário de Cadastro de Funcionários</legend>
							
							<div class="row-fluid">
								<div class="span6">
									<div class="control-group">
										<h:outputLabel id="Nome" value="Nome:" for="Nome" styleClass="control-label" />
										<h:inputText id="nome" value="#{FuncionarioMB.entidade.nome}" maxlength="30"/>
										
									</div>
								</div>
							</div>
							
							<div class="control-group">
								<p:commandButton 
									value="Gravar" 
									action="#{FuncionarioMB.gravar}"
									update="mensagens"
									ajax="false"/>
								
								<span></span>
								
								<p:commandButton 
									value="Voltar" 
									action="#{FuncionarioMB.voltar}"
									immediate="true"
									ajax="false"/>
								
								<span></span>
								
								<p:commandButton 
									value="Excluir" 
									action="#{FuncionarioMB.excluir}"
									rendered="#{FuncionarioMB.exibirExcluir}"
									onclick="confirmation.show()" 
									type="button"
									ajax="false"
									styleClass="pull-right">
								</p:commandButton>
									
								<p:confirmDialog 
									id="confirmDialog" 
									message="Confimar a exclusão do registro?"  
							        header="Confirmação!" 
							        severity="alert" 
							        widgetVar="confirmation">  
						                 
								    <p:commandButton 
							       	id="confirm" 
							       	value="Sim" 
							       	oncomplete="confirmation.hide()"  
							        action="#{FuncionarioMB.excluir}"
							        ajax="false"/>  
							        
							    <p:commandButton 
							       	id="decline" 
							       	value="Não" 
							       	onclick="confirmation.hide()" 
							       	type="button"/>   
							                  
							    </p:confirmDialog>  
							</div>
						</fieldset>
					</h:panelGroup>
			</h:form>
		</ui:define>
	</ui:decorate>
</html>